package demo05

/**
 * @author xiaoZhao
 * @date 2022/7/1
 * @describe 自身类型
 */
object Test16_TraitSelfType {
  def main(args: Array[String]): Unit = {
    val user = new RegisterUser("alice", "1212121")
    user.insert()
  }
}

// 用户类
class User(val name: String,val password: String){

}

trait UserDao{
  // 定义自身类型
  _: User =>
  // 注册用户
  def insert():Unit={
    println (s" insert into db: = ${this.name} , ${this.password}")
  }
}

 // 定义注册用户
class RegisterUser(name: String,password: String) extends User(name,password) with UserDao